package com.qiqu.controller;

import com.qiqu.entity.SearchRecords;
import com.qiqu.service.SearchRecordsService;
import com.qiqu.utils.JSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("searchRecords")
@Api(value = "搜索相关接口",tags = {"搜索相关接口controller"})
public class SearchRecordsController {

    @Resource
    private SearchRecordsService searchRecordsService;

    //添加关键字
    @ApiOperation(value = "添加关键字--fk",notes = "添加关键字")
    @PostMapping("/addKeyword")
    public JSONResult addKeyword(@RequestBody SearchRecords searchRecord) {
        return JSONResult.ok(searchRecordsService.addSearchRecords(searchRecord));
    }

    //查询所有关键字
    @ApiOperation(value = "查询关键字--fk",notes = "查询关键字")
    @GetMapping("/getKeywords")
    public JSONResult getKeywords() {
        return JSONResult.ok(searchRecordsService.queryKeywords());
    }


    @ApiOperation(value = "查询指定用户喜爱关键字--fk",notes = "查询指定用户喜爱关键字")
    @ApiImplicitParam(name="userId",value = "用户Id",required = true,dataType = "string",paramType = "query")
    @GetMapping("/getLikeKeywords")
    public JSONResult getLikeKeywords(String userId) {
        return JSONResult.ok(searchRecordsService.queryLikeKeywords(userId));
    }
}